import { JsonUtil } from "db://app-game/core/utils/JsonUtil";
import { DBLevelType } from "./DBLevel.type";

export class DBLevel {
  /** 表单名称 */
  static DBName = "Level";
  /** 表单数据 */
  data: DBLevelType = null!;

  init(id: number) {
    let db = JsonUtil.get(DBLevel.DBName) as DBLevelType[];
    this.data = db.find((v) => v.id === id)!;
  }
}
const a = {
  mapId: "ancient_forest",
  displayName: "Ancient Forest",
  description: "A dense primal forest with ancient ruins",
  bounds: {
    min: { x: -1500, y: -200, z: -800 },
    max: { x: 1200, y: 500, z: 750 },
  },
  recommendedLevel: [15, 25],
  baseMonsters: [
    {
      monsterId: "rathalos",
      baseCount: 1,
      maxConcurrent: 2,
      respawnInterval: 1800,
      spawnArea: {
        center: { x: 200, y: 50, z: 300 },
        radius: 150,
      },
      spawnConditions: {
        timeRange: [6, 18],
        weather: ["sunny", "cloudy"],
        requiredQuestProgress: 3,
      },
    },
    {
      monsterId: "great_jagras",
      baseCount: 3,
      maxConcurrent: 5,
      respawnInterval: 600,
      spawnArea: {
        center: { x: -400, y: 10, z: -200 },
        radius: 80,
      },
    },
  ],
  weatherSystem: {
    initialWeather: "sunny",
    weatherPool: [
      {
        name: "sunny",
        duration: [15, 25],
        weight: 0.6,
        effects: {
          visibility: 1.0,
          staminaDrainMultiplier: 1.0,
        },
      },
      {
        name: "rain",
        duration: [10, 20],
        weight: 0.3,
        effects: {
          visibility: 0.7,
          staminaDrainMultiplier: 1.2,
          monsterBehaviorChanges: [
            {
              monsterId: "rathalos",
              aggressionLevel: 0.8,
              movementSpeedMultiplier: 0.9,
            },
          ],
        },
      },
    ],
    dayNightCycle: {
      enabled: true,
      dayDuration: 40,
      nightDuration: 20,
    },
  },
  npcSpawns: [
    {
      type: "QUEST_GIVER",
      position: { x: 120, y: 30, z: -50 },
      rotation: { x: 0, y: 180, z: 0 },
      interactionType: "DIALOG",
      availableQuests: ["forest_guardian"],
    },
  ],
  activeQuests: [
    {
      questId: "forest_guardian",
      title: "Forest Guardian",
      description: "Hunt the raging Rathalos",
      objectives: [
        {
          type: "KILL",
          target: "rathalos",
          required: 1,
          current: 0,
        },
      ],
      rewards: {
        experience: 5000,
        items: [{ itemId: "rathalos_plate", quantity: 1 }],
      },
    },
  ],
  globalRules: {
    maxDeaths: 3,
    timeLimit: 50,
    dynamicDifficulty: {
      playerCountScaling: true,
      scaleFactors: {
        monsterHealth: 0.3,
        monsterDamage: 0.2,
      },
    },
    eventTriggers: [
      {
        condition: "QUEST_COMPLETION",
        value: "forest_guardian",
        action: "SPAWN_BOSS",
      },
    ],
  },
};
